package com.zhongyi.mail;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;


public class TestNio {
	public static void main(String[] args) {
		String strFile = "c:\\test.html";
		FileInputStream fis;
		String htmlText = "";
		try {
			fis = new FileInputStream(new File(strFile));
			FileChannel fc = fis.getChannel();
			ByteBuffer bufer = ByteBuffer.allocate(1024);
			byte[] by = new byte[1024];
			while(fc.read(bufer) != -1){
				htmlText += bufer.get(by).asCharBuffer().toString();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println(htmlText);
	}
}
